home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / B_INITVA.C < prev    next >
Text File  |  1991-09-15  |  15KB  |  444 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*          This module was originally written by Vince Perriello           */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Variable Initialization                    */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. void compile_externs (void);
  51. void fillin_defaults (struct secure *, struct secure *);
  52.  
  53. /**
  54.  ** b_initvars -- called before parse_config. Sets defaults that we want
  55.  ** to have set FIRST.
  56.  **/
  57.  
  58.  
  59. void b_initvars ()
  60. {
  61.     int k;
  62.     char *envp;
  63.     BINK_EVENT far *p;
  64.     BINK_EVENT foo;
  65.  
  66.     if ((envp = getenv ("TZ")) != NULL)
  67.         {
  68.         if ((saved_TZ = calloc( 1, 4 + strlen (envp))) != NULL)
  69.             {
  70.             (void) strcpy (saved_TZ, "TZ=");
  71.             (void) strcat (saved_TZ, envp);
  72.             }
  73.         }
  74.  
  75.     (void) putenv ("TZ=GMT0");
  76.     tzset ();
  77.  
  78.  
  79.     p = (BINK_EVENT far *) _fmalloc( 256 * sizeof (BINK_EVENT));
  80.     if (p == (BINK_EVENT far *) NULLGLOBALPTR)
  81.         {
  82.         (void) printf (MSG_TXT(M_BAD_EVENT_ALLOC));
  83.         exit (252);
  84.         }
  85.  
  86.     (void) memset ((char *)&foo, 0 , sizeof (foo));
  87.  
  88.     e_ptrs = p;
  89.  
  90.     for (k = 0; k < 256; k++)
  91.         {
  92.         *p++ = foo;
  93.         }
  94.  
  95.     (void) memset ((char *)&DEFAULT, 0 , sizeof (DEFAULT));
  96.  
  97.     KNOWN = DEFAULT;                            /* Does some of the work      */
  98.     KNOWN.rq_Limit = -1;
  99.     KNOWN.byte_Limit = -1L;
  100.     KNOWN.time_Limit = -1;
  101.     KNOWN.rq_Cum_Limit = -1;
  102.     KNOWN.byte_Cum_Limit = -1L;
  103.     KNOWN.time_Cum_Limit = -1L;
  104.  
  105.     PROT = KNOWN;                               /* Initially the same default */
  106.  
  107.     for (k = 0; k < 10; k++)                    /* Zero the phone scan list   */
  108.         {
  109.         scan_list[k] = NULL;
  110.         }
  111.  
  112.     for (k = 0; k < MAX_EXTERN; k++)            /* And the external protocols */
  113.         {
  114.         protocols[k] = NULL;
  115.         }
  116.  
  117.     for (k = 1; k < ALIAS_CNT; k++)             /* And the alias list         */
  118.         {
  119.         alias[k].Zone = alias[k].Net = alias[k].Node = alias[k].Point = 0;
  120.         alias[k].Domain = NULL;
  121.         }
  122.  
  123.     alias[0].Zone = 1;                          /* Make sure we have a zone   */
  124.     alias[0].Net = alias[0].Node = (unsigned) -1;  /* Default Fidonet address */
  125.     alias[0].Point = 0;
  126.     alias[0].Domain = NULL;
  127.  
  128. #ifdef Snoop
  129.     pipename[0] = '\0';                         /* Make sure we have no name  */
  130.     if (getenv("SNOOPPIPE") != NULL)
  131.        {
  132.        strcpy (pipename, getenv("SNOOPPIPE"));
  133.        snoop_open(pipename);
  134.        }
  135. #endif
  136.  
  137.     b_init ();
  138.  
  139.     baud = 2;
  140.     cur_baud = btypes[baud];
  141.     command_line_un = 0;
  142.  
  143.     (void) memset (&dta_str, 0, sizeof (dta_str));
  144.  
  145. }
  146.  
  147. /**
  148.  ** b_defaultvars -- called after all parse_config passes complete.
  149.  ** sets anything not handled by parse_config to default if we know it.
  150.  **/
  151.  
  152.  
  153. void b_defaultvars ()
  154. {
  155.     int i;
  156.     char *p;
  157.  
  158.     if (!fullscreen)
  159.         do_screen_blank = 0;
  160.  
  161.     if (version7)
  162.         nodelist_name = "NODEX";
  163.     else
  164.         nodelist_name = "NODELIST";
  165.  
  166.     if (modem_init == NULL)
  167.         modem_init = ctl_string ("|AT|");
  168.     if (modem_busy == NULL)
  169.         modem_busy = ctl_string ("|AT|");
  170.  
  171.     if (net_info == NULL)
  172.         net_info = ctl_string (".\\");
  173.  
  174.  
  175.     /* Set up "boss" and "point" addresses correctly if we can */
  176.  
  177.     if (boss_addr.Zone == 0)
  178.         boss_addr.Zone = alias[0].Zone;
  179.  
  180.     if (boss_addr.Net == 0)
  181.         {
  182.         boss_addr = alias[0];
  183.         boss_addr.Point = 0;
  184.         }
  185.  
  186.     if ((pvtnet >= 0) && (alias[0].Point != 0))
  187.         {
  188.         my_addr = boss_addr;
  189.         my_addr.Point  = alias[0].Point;
  190.         alias[0].Net   = (unsigned) pvtnet;
  191.         alias[0].Node  = alias[0].Point;
  192.         alias[0].Point = 0;
  193.         }
  194.     else
  195.         my_addr = alias[0];
  196.  
  197.     /* If we have the minimum information to do netmail, set the flag */
  198.  
  199.     if ((alias[0].Zone      != 0)
  200.     &&  (alias[0].Net       != 0)
  201.     &&  (system_name        != NULL)
  202.     &&  (sysop              != NULL)
  203.     &&  (hold_area          != NULL)
  204.     &&  (DEFAULT.sc_Inbound != NULL))
  205.         {
  206.         net_params = 1;
  207.         (void) flag_file (INITIALIZE, &alias[0], 0);
  208.         }
  209.  
  210.     if (system_name == NULL)
  211.         system_name = "";
  212.  
  213.     if (hold_area == NULL)
  214.         hold_area = ctl_string (".\\");
  215.  
  216.     if (DEFAULT.sc_Inbound == NULL)
  217.         DEFAULT.sc_Inbound = ctl_string (".\\");
  218.  
  219.     /* Make the "higher class" requests at least as well off as the
  220.         "lowest class"... */
  221.  
  222.     fillin_defaults (&KNOWN, &DEFAULT);
  223.     fillin_defaults (&PROT, &KNOWN);
  224.  
  225.     if (extern_index)
  226.         compile_externs ();                     /* generate extern_protocols  */
  227.  
  228.     if (!colors.calling && colors.hold)
  229.         colors